package gaotingkunserialization;

import java.io.Serializable;

//声明Person类的Serializable接口
public class Person implements Serializable {
    //显式定义serialVersionUID
    private static final long serialVersionUID = 1L;
    /*
    private static final long serialVersionUID = 1L;
    作用;
    版本标识:唯一标识类的序列化版本
    兼容性控制:确保序列化/反序列化版本匹配
    稳定性:防止自动生成的UID因类结构微调而改变
    向前兼容:允许类演进同时保持对旧数据的兼容
     */

    //姓名
    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    //年龄
    private int age;
    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    //身高
    private double height;
    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        this.height = height;
    }

    //体重
    private double weight;
    public double getWeight() {
        return weight;
    }

    public void setWeight(double weight) {
        this.weight = weight;
    }

    //电话号码
    private String number;
    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", height=" + height +
                ", weight=" + weight +
                ", number='" + number + '\'' +
                '}';
    }


    // 构造方法
    public Person(String name, int age, double height, double weight, String number) {
        this.name = name;
        this.age = age;
        this.height = height;
        this.weight = weight;
        this.number = number;
    }

}